package com.ha7419x.controller;

import com.ha7419x.entity.User;
import com.ha7419x.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    private IUserService userService;

    @GetMapping
    public List<User> queryUserList() {
        return userService.selectList();
    }

    @PostMapping
    public void addUser(@RequestBody User user) {
        userService.save(user);
    }

    @PutMapping
    public void updateUser(@RequestBody User user) {
        userService.updateById(user);
    }

    @DeleteMapping
    public void deleteUser(@RequestParam Long id) {
        userService.removeById(id);
    }
}
